{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "# Bisection Method"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 1,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "import numpy as np\n",
        "import matplotlib.pyplot as pt"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 2,
      "metadata": {
        "collapsed": false
      },
      "outputs": [
        {
          "data": {
            "text/plain": [
              "[<matplotlib.lines.Line2D at 0x7f429c3f2438>]"
            ]
          },
          "execution_count": 2,
          "metadata": {},
          "output_type": "execute_result"
        },
        {
          "data": {
            "image/png": "iVBORw0KGgoAAAANSUhEUgAAAX4AAAEACAYAAAC08h1NAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3XucXfO5x/HPI+6SGoQQwqR1q7YxiVuKstUtoqgUpbwY\nTtWlrkWJy0mLcxKnpZFWNa6jLaGKSogSPbNd6ohbJsIkSCXkIpe6JCTFJPOcP357zHSy57L3XrPX\nWjPf9+u1X3uvvX+z17e/xjN7nr3Wb5m7IyIiPcdacQcQEZHyUuEXEelhVPhFRHoYFX4RkR5GhV9E\npIdR4RcR6WFKKvxmNsDMas3sdTN7zczOyzMmY2bLzGxa7nZlKfsUEZHSrF3izzcAF7p7nZn1Bl42\nsynuPrPVuKfc/cgS9yUiIhEo6RO/uy9y97rc40+AmUD/PEOtlP2IiEh0Iuvxm1klMBiY2uolB/Y2\ns+lmNtnMdolqnyIiUrhSWz0A5No8fwbOz33yb+kVYIC7rzSzw4C/ADtGsV8RESmclbpWj5mtAzwC\nPObuYzsxfg6wm7t/0Op5LRokIlIEdy+onV7qUT0G3A7Ut1X0zaxfbhxmtifhl80H+ca6e+Jvo0aN\nij1Dd8ionMqZ9Ftachaj1FbPPsBJwKtmNi333OXAtrlCPh44BjjLzFYBK4HjS9xnrObOnRt3hA6l\nISMoZ9SUM1ppyVmMkgq/uz9LB381uPtNwE2l7EdERKKjM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E65+cVspc6gQuEZEeRleA\nFRHpYVT4RUR6GBV+EZEeRoVfRKSHUeEXEelhVPhFRHoYFX4RkR5GhV9EpIf5f9XxmxP3Z/NIAAAA\nAElFTkSuQmCC\n",
            "text/plain": [
              "<matplotlib.figure.Figure at 0x7f429c3f24a8>"
            ]
          },
          "metadata": {},
          "output_type": "display_data"
        }
      ],
      "source": [
        "a = 2\n",
        "b = 6\n",
        "\n",
        "x = np.linspace(a, b)\n",
        "\n",
        "def f(x):\n",
        "    return 1e-2 * np.exp(x) - 2\n",
        "\n",
        "pt.grid()\n",
        "pt.plot(x, f(x))"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "Write code for the bisection method and run it in-place many times: (Ctrl-Enter)"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 25,
      "metadata": {
        "collapsed": false
      },
      "outputs": [
        {
          "name": "stdout",
          "output_type": "stream",
          "text": [
            "5.298316955566406 5.2983174324035645\n"
          ]
        }
      ],
      "source": [
        "m = (a+b)/2\n",
        "\n",
        "if np.sign(f(a)) == np.sign(f(m)):\n",
        "    a = m\n",
        "else:\n",
        "    b = m\n",
        "        \n",
        "print(a, b)"
      ]
    }
  ],
  "metadata": {},
  "nbformat": 4,
  "nbformat_minor": 0
}